package com.shensi.api.pay.client;

import com.alibaba.fastjson.JSONObject;
import com.shensi.api.pay.param.request.PayInfoRequest;
import com.shensi.api.pay.param.request.PayOrderRequest;
import com.shensi.api.pay.param.request.PosUpdateOrderStatus;
import com.shensi.api.pay.pojo.PayOrder;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.api.pay.param.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Objects;

/***
 * <Title> QuJiaPayController </Title>
 * <Description> 趣加 新版小程序订单 App生成订单，与调用第三方支付控制层 </Description>
 * <Date>2021年10月28日</Date>
 */

@Api(tags = "趣加App支付")

@FeignClient(name = CloudConstant.PAY_SERVER)
public interface QuJiaPayClient {


    @ApiOperation(value = "根据订单和选择的优惠券id以及立减活动id计算优惠", httpMethod = "POST", notes = "根据订单和选择的优惠券id以及立减活动id计算优惠")
    @PostMapping(value = "/calculateCouponAndActivity", produces = "application/json;charset=UTF-8")
    @Transactional
    public String calculateCouponAndActivity(@RequestBody PayOrder payOrderInfo);

    /*
     * 小程序创建加油支付订单
     * @param payOrderRequest
     * @return
     */
    @ApiOperation(value = "小程序创建加油支付订单", httpMethod = "POST", notes = "小程序创建加油支付订单")
    @PostMapping(value = "/createPayOrder", produces = "application/json;charset=UTF-8")
    @Transactional(rollbackFor = Exception.class)
    public String createPayOrder(@RequestBody PayOrderRequest payOrderRequest);


    @GetMapping("/GetOrderNo")
    public long getOrderNo();

    /*
     * 小程序消费支付拉起第三方支付
     * @param payInfoRequest
     * @return
     */
    @ApiOperation(value = "消费支付拉起第三方支付", httpMethod = "POST", notes = "消费支付拉起第三方支付")
    @PostMapping(value = "/toThirdPayment")
    public String toThirdPayment(@RequestBody PayInfoRequest payInfoRequest);

    @ApiOperation(value = "消费支付拉起第三方支付", httpMethod = "POST", notes = "消费支付拉起第三方支付不包含活动")
    @PostMapping(value = "/toThirdPaymentNotContainActivity")
    @Transactional
    public String toThirdPaymentNotContainActivity(@RequestBody PayInfoRequest payInfoRequest);


    /*
     * 小程序消费 通联智U+，需要实时到账，分账时预支付接口 回调
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping(value = "/tLFusClassPayCallback", consumes = "application/x-www-form-urlencoded", method = RequestMethod.POST)
    @Transactional
    public void tLFusClassPayCallback(@RequestParam("request") HttpServletRequest request, @RequestParam("response") HttpServletResponse response);

    /*
     * 小程序消费  通联收银宝异步回调通知
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping(value = "/tLPayCallback", consumes = "application/x-www-form-urlencoded", method = RequestMethod.POST)
    @Transactional
    public void tLPayCallback(@RequestParam("request") HttpServletRequest request, @RequestParam("response") HttpServletResponse response);


    /*
     * 小程序消费  随行付异步回调通知
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping(value = "/sxfPayCallback", consumes = "application/json", method = RequestMethod.POST)
    @Transactional
    public JSONObject sxfPayCallback(@RequestBody JSONObject request);

    /*
     * 小程序消费  云闪付扫呗回调
     * @param params
     * @return
     */
    @RequestMapping(value = "/sbPayCallback", consumes = "text/xml", method = RequestMethod.POST)
    @Transactional
    public net.sf.json.JSONObject sbPayCallback(@RequestBody String params);

    @GetMapping(value = "/getUserOrderListByUnionId")
    @ApiOperation(value = "根据用户unionId、油站ID或油企ID查询用户订单（消费记录）", httpMethod = "GET", notes = "根据用户unionId、stationId或油企ID查询用户订单（消费记录）")
    public String getUserOrderListByUnionId(@RequestParam("mobilePhone") String mobilePhone,
                                            @RequestParam("enterpriseId") Integer enterpriseId,
                                            @RequestParam("pageSize") Integer pageSize,
                                            @RequestParam("pageNum") Integer pageNum,
                                            @RequestParam(value = "stationId", required = false) Integer stationId,
                                            @RequestParam(value = "stationId", required = false) String oilName);

    /*
     * 根据订单号获取订单信息
     * @RequestBody String orderno
     * @param orderNo
     * @return
     */
    @GetMapping(value = "/selectOrderInfoByOrdNo")
    @ApiOperation(value = "根据订单号获取订单信息", httpMethod = "GET", notes = "根据订单号获取订单信息")
    public String getPayOrderList(@RequestParam("orderNo") String orderNo);

    //现金或刷卡银联支付 pos机上
    @PostMapping(value = "createCashOrUnionPayOrder")
    @ApiOperation(value = "现金支付创建订单", httpMethod = "POST")
    @Transactional
    public String createCashOrUnionPayOrder(@RequestBody PayOrderRequest payOrderRequest);


    /*
     * 小程序现金支付
     * @param payOrderRequest
     * @return
     */
    @GetMapping("/payAppCashOrder")
    @ApiOperation(value = "小程序现金支付")
    @Transactional
    public String payAppCashOrder(@RequestParam("ordNo") String ordNo, @RequestParam(value = "couponUserId", required = false) String couponUserId);

    /*
     * 轮询 小程序现金支付订单状态
     * @param payOrderRequest
     * @return
     */
    @GetMapping("/selectCashOrderStatus")
    @ApiOperation(value = "轮询 小程序现金支付订单状态")
    @Transactional
    public String selectCashOrderStatus(@RequestParam("ordNo") String ordNo);

    /*
     * 小程序取消现金支付订单
     * @param payOrderRequest
     * @return
     */
    @GetMapping("/cancelCashOrder")
    @ApiOperation(value = "小程序取消现金支付订单")
    @Transactional
    public String cancelCashOrder(@RequestParam("ordNo") String ordNo);


    /*
     * 小程序现金支付pos修改订单状态
     * @param payOrderRequest
     * @return
     */
    @PostMapping("/posUpdateOrderStatus")
    @ApiOperation(value = "pos修改订单状态")
    @Transactional
    public String posUpdateOrderStatus(@RequestBody PosUpdateOrderStatus puos);

    @GetMapping("/order/payTypes")
    @ApiOperation(value = "查询除固定支付方式之外用户自定义的支付方式")
    public ResultData getOrderPayTypes(@RequestParam("stationId") Long stationId);

    @PostMapping(value = "/createCashOrderPayType")
    @ApiOperation(value = "油站定义支付方式生成订单入口", httpMethod = "POST")
    @Transactional
    public ResultData createCashOrderPayType(@RequestBody PayOrderRequest payOrderRequest);


}
